package org.hilo.boot.core.metrics;

import org.springframework.boot.actuate.autoconfigure.metrics.export.properties.StepRegistryPropertiesConfigAdapter;

import io.micrometer.influx.InfluxConfig;
import io.micrometer.influx.InfluxConsistency;

/**
 * Adapter to convert {@link InfluxV2Properties} to an {@link InfluxConfig}.
 *
 * @author zollty
 * @author Jon Schneider
 * @author Phillip Webb
 */
class InfluxPropertiesConfigDecorator
        extends StepRegistryPropertiesConfigAdapter<InfluxV2Properties>
        implements InfluxConfig {

    InfluxPropertiesConfigDecorator(InfluxV2Properties properties) {
        super(properties);
    }

    @Override
    public String prefix() {
        return "management.metrics.export.influx";
    }

    @Override
    public String db() {
        return get(InfluxV2Properties::getDb, InfluxConfig.super::db);
    }

    @Override
    public InfluxConsistency consistency() {
        return get(InfluxV2Properties::getConsistency, InfluxConfig.super::consistency);
    }

    @Override
    public String userName() {
        return get(InfluxV2Properties::getUserName, InfluxConfig.super::userName);
    }

    @Override
    public String password() {
        return get(InfluxV2Properties::getPassword, InfluxConfig.super::password);
    }

    @Override
    public String retentionPolicy() {
        return get(InfluxV2Properties::getRetentionPolicy, InfluxConfig.super::retentionPolicy);
    }

    @Override
    public Integer retentionReplicationFactor() {
        return get(InfluxV2Properties::getRetentionReplicationFactor,
                InfluxConfig.super::retentionReplicationFactor);
    }

    @Override
    public String retentionDuration() {
        return get(InfluxV2Properties::getRetentionDuration, InfluxConfig.super::retentionDuration);
    }

    @Override
    public String retentionShardDuration() {
        return get(InfluxV2Properties::getRetentionShardDuration,
                InfluxConfig.super::retentionShardDuration);
    }

    @Override
    public String uri() {
        return get(InfluxV2Properties::getUri, InfluxConfig.super::uri);
    }

    @Override
    public boolean compressed() {
        return get(InfluxV2Properties::isCompressed, InfluxConfig.super::compressed);
    }

    @Override
    public boolean autoCreateDb() {
        return get(InfluxV2Properties::isAutoCreateDb, InfluxConfig.super::autoCreateDb);
    }

    @Override
    public String bucket() {
        return get(InfluxV2Properties::getBucket, InfluxConfig.super::bucket);
    }

    @Override
    public String token() {
        return get(InfluxV2Properties::getToken, InfluxConfig.super::token);
    }

    @Override
    public String org() {
        return get(InfluxV2Properties::getOrg, InfluxConfig.super::org);
    }

}
